package com.gitee.dolt.core.exception;


import cn.hutool.core.util.StrUtil;
import com.gitee.dolt.core.exception.code.BaseExceptionCode;
import lombok.Data;
import lombok.experimental.Accessors;

/**
 * 业务异常
 * 用于在处理业务逻辑时，进行抛出的异常。
 *
 * @author LYH
 */
@Data
@Accessors(chain = true)
public class BizException extends RuntimeException {

    private int code;
    private String msg;

    public BizException(int code, String msg) {
        super(msg);
        this.code = code;
        this.msg = msg;
    }


    public BizException(BaseExceptionCode exceptionCode) {
        this(exceptionCode.getCode(), exceptionCode.getMsg());
    }


    public BizException(int code, String format, Object... args) {
        this(code, StrUtil.format(format, args));
    }


}
